{include file="header.html"}
<body class="gr">

<div class="navBar">
	<a class="left" href="javascript:history.back()"><i class="return"></i></a>
	<div class="titleView-x">选择参保月份</div>
</div>

<div class="cart-month main-top">
	<div class="month clear-after">
		{foreach from=$data.years item=g}
		<a href="javascript:void(0)" class="view" year="{$g->year}" month="{$g->month}" disabled="{$g->disabled}"><span>{$g->year}年</span>{$g->month}月</a>
		{/foreach}
	</div>
	
	<div class="tip">当前月份为：{$data.year}年{$data.month}月</div>
	
	<div class="buttonView">
		<a href="javascript:void(0)" class="btn">提交</a>
	</div>
</div>

{include file="footer.html"}
<script>
$(function(){
	bodyView.find('.month a[disabled="0"]').click(function(){
		var _this = $(this), index = _this.index(), parent = _this.parent();
		if(!parent.find('.view-x').length){
			_this.addClass('view-x');
		}else{
			var first = parent.find('.view-x:eq(0)'), firstIndex = first.index();
				last = parent.find('.view-x:last'), lastIndex = last.index();
			if(index==firstIndex && index==lastIndex){
				_this.removeClass('view-x');
			}else if(index==firstIndex || index==lastIndex){
				_this.removeClass('view-x');
			}else if(index<firstIndex){
				_this.addClass('view-x').nextUntil(first).filter('[disabled="0"]').addClass('view-x');
			}else if(index>lastIndex){
				last.nextUntil(_this).filter('[disabled="0"]').addClass('view-x');
				_this.addClass('view-x');
			}else{
				parent.find('.view-x').removeClass('view-x');
				first.addClass('view-x').nextUntil(_this).filter('[disabled="0"]').addClass('view-x');
				_this.addClass('view-x');
			}
		}
	});
	bodyView.find('.btn').click(function(){
		var month = [];
		bodyView.find('.month a.view-x').each(function(){
			month.push($(this).attr('year')+'-'+$(this).attr('month'));
		});
		
	});
});
</script>